-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement System.Runtime.InteropServices.CLong/CULong/NFloat #46401
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
|
||
namespace System.Runtime.InteropServices | ||
{ | ||
[CLSCompliant(false)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means this type isn't compliant in VB.NET. Which means APIs that decide to use it will not be consumable by VB.NET. Unsure if that is okay or not. I am fine with it but let's make sure we do our due diligence and confirm that shared understanding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think CLong
can be CLSCompliant
since it is signed and internally an int
or nint
, which both are CLSCompliant
. However, I don't think CLSCompliant
means it isn't consumable by VB.NET, using other types like UIntPtr
or SByte
seem to work just fine: https://sharplab.io/#v2:DYLgbgRgNALiCWwA+BJAtgBwPYCcYGcACAZQE98YBTNAWACgAFAVwmHgGNCBhYAQ3yJd6hEYWasOhAGJMAduxjwsswgFkAjAAoAlIQCCRAKopZMBjBzDR1gEqUYTHCuOnzOAHQAtSjixWRAKKyACbScgpKsv6E0eJsnDLyispqAEw6+kTEAEKkVNG29o4qALTq0UGhiRHK9JXcfAJAA=
I'm no expert in VB though, so it's definitely plausible that I'm unaware of some detail 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLSCompilant(false)
just means that some or all of the members use types that are not guaranteed to be usable from all languages. The types themselves are still usable, but some members (like the uint
constructor on CULong
) aren't supported. It doesn't block the types from being used in VB.NET.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything actually preventing the use of this from other languages given it is just a struct wrapping a CLSCompliant
type?
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs
Show resolved
Hide resolved
@@ -8028,6 +8033,21 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |||
#endif | |||
} | |||
|
|||
bool isIntrinsicType(CORINFO_CLASS_HANDLE clsHnd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was it just moved or do I miss an actual change for these 3 functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was just moved out of the FEATURE_SIMD block.
{ | ||
canReturnInRegister = false; | ||
howToReturnStruct = SPK_ByReference; | ||
useType = TYP_UNKNOWN; | ||
} | ||
#elif defined(TARGET_WINDOWS) && !defined(TARGET_ARM) | ||
if (callConvIsInstanceMethodCallConv(callConv)) | ||
if (callConvIsInstanceMethodCallConv(callConv) && !isNativePrimitiveStructType(clsHnd)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, it looks like this call is expensive, should we measure TP on x64 windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be expensive since its initially filtered on isIntrinsicType
, which should just be a simple cached flag check?
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CLong.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/CULong.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Runtime.InteropServices/tests/System/Runtime/InteropServices/NFloatTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NFloat.cs
Outdated
Show resolved
Hide resolved
@tannergooding any suggestions on how to get the ToString tests passing on the Spanish culture Helix queues? |
Any reason we can't just say |
Mono failures are due to #46820. I'll disable the ThisCall test on Mono against that issue. |
Now that CI is green, can I get another review pass on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jit changes LGTM
Allconfigurations failure fixed by #46866 |
Fixes #13788
Implements the System.Runtime.InteropServices.CLong, CULong and, NFloat types along with code to recognize them as JIT intrinsics in the unmanaged calling convention.
Includes framework tests for the APIs and updates to the ThisCall runtime test to validate the special JIT behavior.
cc: @dotnet/jit-contrib for the JIT changes.